package co.com.services.zona;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.ZonaDTO;
import co.com.smart.session.DelegateContextEJB;

@Path("/SmartZonaServices")
public class ZonaServices {
	@GET
	@Path("/getAllZona")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getZona() throws NamingException{
		return Response.ok(DelegateContextEJB.getZonaBeanLocal().consultarAllZona())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
	
	@POST
	@Path("/getZonaId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getZonaId(ZonaDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getZonaBeanLocal().consultarZonaId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setZona")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setZona( ZonaDTO json){ 
		return Response.ok(DelegateContextEJB.getZonaBeanLocal().insertarZona(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editZona")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditZona(ZonaDTO json){ 
		return Response.ok(DelegateContextEJB.getZonaBeanLocal().editZona(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeZona")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveZona(ZonaDTO json){ 
		return Response.ok(DelegateContextEJB.getZonaBeanLocal().removeZona(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
	
	@POST
	@Path("/filtrarzonaxciudad")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getFiltrarzonaxciudad(ZonaDTO json) throws NamingException{
		return Response.ok(DelegateContextEJB.getZonaBeanLocal().filtrarzonaxciudad(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
}
